class PaneMatrix
    attr_accessor :panes,:window,:choices
  def initialize(gui)
    @mgr = gui.instance_variable_get("@mgr")
    @gui =gui
    @panes = []
  end
  def add pane
    @panes << pane
  end
  def show
    @choices = []
    @window = Wx::Frame::new @gui,-1,"Pane Matrix",:style=>Wx::STAY_ON_TOP|Wx::FRAME_TOOL_WINDOW|Wx::DEFAULT_FRAME_STYLE
    @window.sizer = Wx::StaticBoxSizer::new(Wx::VERTICAL,@window,"Pane Matrix")
    @panes.each {|pane|
      @choices << pane.get_name
    }
    @paneList = Wx::Choice::new @window,-1,:choices=>@choices
    @window.sizer.add @paneList
    bs = Wx::BoxSizer::new Wx::HORIZONTAL
    @window.sizer.add bs
    bs.add Wx::Button::new(@window,7819,"Show")
    bs.add Wx::Button::new(@window,7818,"Hide")
    bs.add Wx::Button::new(@window,7817,"Float")
    bs.add Wx::Button::new(@window,7816,"Dock")
    @window.evt_button(7819) {|evt| evt_do(evt,7819) }
    @window.evt_button(7818) {|evt| evt_do(evt,7818) }
    @window.evt_button(7817) {|evt| evt_do(evt,7817) }
    @window.evt_button(7816) {|evt| evt_do(evt,7816) }
    bs2 = Wx::BoxSizer::new Wx::HORIZONTAL
    @window.sizer.add bs2
    bs2.add Wx::Button::new(@window,7811,"Top")
    bs2.add Wx::Button::new(@window,7810,"Left")
    bs2.add Wx::Button::new(@window,7809,"Right")
    bs2.add Wx::Button::new(@window,7808,"Center")
    bs2.add Wx::Button::new(@window,7807,"Bottom")
    @window.evt_button(7811) {|evt| evt_do(evt,7811) }
    @window.evt_button(7810) {|evt| evt_do(evt,7810) }
    @window.evt_button(7809) {|evt| evt_do(evt,7809) }
    @window.evt_button(7808) {|evt| evt_do(evt,7808) }
    @window.evt_button(7807) {|evt| evt_do(evt,7807) }
    bs1 = Wx::BoxSizer::new Wx::HORIZONTAL
    bs1.add Wx::Button::new(@window,7815,"Float All")
    bs1.add Wx::Button::new(@window,7814,"Dock All")
    bs1.add Wx::Button::new(@window,7813,"Show All")
    bs1.add Wx::Button::new(@window,7812,"Hide All")
    @window.evt_button(7815) {|evt| evt_do(evt,7815) }
    @window.evt_button(7814) {|evt| evt_do(evt,7814) }
    @window.evt_button(7813) {|evt| evt_do(evt,7813) }
    @window.evt_button(7812) {|evt| evt_do(evt,7812) }
    @window.sizer.add bs1
    @window.show
  end
  def evt_do(evt,id)
    name = @choices[@paneList.get_selection]
    case id
      when 7819
         @mgr.get_pane(name).show
      when 7818
         @mgr.get_pane(name).hide
      when 7817
         @mgr.get_pane(name).show.float
      when 7816
         @mgr.get_pane(name).dock
      when 7815
         @choices.each {|pane|
           @mgr.get_pane(pane).show.float
         }
      when 7814
         @choices.each {|pane|
           @mgr.get_pane(pane).dock
         }
      when 7813
         @choices.each {|pane|
           @mgr.get_pane(pane).show
         }
      when 7812
         @choices.each {|pane|
           @mgr.get_pane(pane).hide
         }
      when 7811
        @mgr.get_pane(name).top.show
      when 7810
        @mgr.get_pane(name).left
      when 7809
        @mgr.get_pane(name).right
      when 7808
        @mgr.get_pane(name).center
      when 7807
        @mgr.get_pane(name).bottom
    end
    @mgr.update
  end
  def hide
    @window.destroy
  end
end